
import { RouteSwitchTabEnum } from '@/core/enum';

/**
 * 用来跳转底部4个导航
 * @param name 传导航名字 
 */
export const handleRouteSwitchTab = (name : RouteSwitchTabEnum = RouteSwitchTabEnum.home) => {
	let url : string = '';
	if (name === RouteSwitchTabEnum.home) {
		url = '/pages/home/home';
	} else if (name === RouteSwitchTabEnum.classify) {
		url = '/pages/classify/classify';
	} else if (name === RouteSwitchTabEnum.cart) {
		url = '/pages/cart/cart';
	} else if (name === RouteSwitchTabEnum.member) {
		url = '/pages/member/member';
	}
	uni.switchTab({ url, });
}

/**
 * 保留当前页面，跳转
 * @param url 页面地址 
 */
export const handleRouteNavigateTo = (url : string) => {
	if (url) {
		uni.navigateTo({ url });
	}
}

/**
 * 关闭当前页面，跳转
 * @param url 页面地址
 */
export const handleRouteRedirectTo = (url : string) => {
	if (url) {
		uni.redirectTo({ url, });
	}
}

/**
 * 关闭所有页面，跳转
 * @param url 页面地址
 */
export const handleRouteReLaunch = (url : string) => {
	if (url) {
		uni.reLaunch({ url, });
	}
}